1. Field of the Invention
The present invention relates to an amount-of-data control method for controlling the compression rate such that the amount of compressed data can be equal to a target amount of data in a case where still image data is to be compressed and transmitted or recorded and to an image data compressing apparatus applying the amount-of-data control.
2. Description of the Related Art
Various standardization methods such as JPEG have been proposed for standardization of still image encoding.
FIG. 6 is a schematic diagram showing processing steps of JPEG. The system divides one input image into multiple blocks each having 8×8 pixels, performs two-dimensional discrete cosine transform (DCT) on each of the blocks (step P1) and performs quantization by dividing the resulting DCT coefficient by each threshold of the quantization matrix including 8×8 thresholds (step P2).
FIGS. 7 and 8 are examples of the quantization matrices for intensity signals and color-difference signals.
A difference is obtained between the direct current (DC) component of the quantized DCT coefficient and the DC component quantized in the previous block, and Huffman encoding is performed on the number of bits of the difference. Zigzag scan is performed on the alternate current (AC) component within each of the blocks to convert to a one-dimensional progression, and two-dimensional Huffman encoding is performed thereon with the number of bits of the valid coefficient and the number of serial zeros (invalid coefficient) (steps P3 and P4). FIG. 9 shows a table of the zigzag scan.
Notably, in the quantization in step P2, each threshold value of the quantization matrix is multiplexed by a certain coefficient (scale factor) and is then divided by a DCT coefficient. The scale factor is a value expressed by “2^S” (where S=0, ±1, ±2 . . . , and ^ is a power). The multiplication of each threshold value of the quantization matrix by 2^S is equivalent to the bit shift of the data of each threshold value. The image quality and compression rate of a compressed image may be adjusted by the scale factor.
The thus compressed data is expanded by the reverse steps of steps P1 to P4. In other words, Huffman decoding in step P5, the decoding of the DC component and AC component in step P6, the inverse quantization in step P7 and the inverse DCT (IDCT) in step P8 are performed.
By the way, since this system uses Huffman codes, which are variable length codes, for data compression, it is difficult to know the entire amount of compressed data until the end of the compression process (steps P1 to P4). Therefore, some control over the amount of data is desirable for encoding within a predetermined range of amounts of data. In the past, multiple kinds of scale factor are used for compression, and the amount of compressed data is measured for each case, and the relationships between the scale factors and the amounts of compressed data are obtained. Then, the scale factor corresponding to a given amount of compressed data is inferred from analogy, and data compression is performed with the scale factor by analogy.
Based on measurement results on many images, the relationship between an amount of compressed data and a scale factor is verified as:[Amount of Data]=A·log [Scale Factor]+B (where A and B: constants determined by a measurement point)
Therefore, A and B are obtained from a measurement result, and the scale factor to the target amount of compressed data can be estimated therefrom (refer to JP-A-3-224362 (Patent Document 1)).